/// 
/// @ProjectName:    umeng_vertify
/// @Package:        lib
/// @ClassName:      result_value
/// @Description:    dart文件作用 
/// @Author:         孙浩
/// @CreateDate:     2021/8/30 7:39 下午
class ResultValue {
  final int type;

  const ResultValue._(this.type);

  ///获取token成功
  static const ResultValue getTokenSuccess = ResultValue._(600000);

  ///唤起授权页成功
  static const ResultValue pageOpenSuccess = ResultValue._(600001);

  ///唤起授权页失败
  static const ResultValue pageOpenError = ResultValue._(600002);

  ///获取运营商配置信息失败
  static const ResultValue operatorInfoError = ResultValue._(600004);

  ///手机终端不安全
  static const ResultValue unSafe = ResultValue._(600005);

  ///未检测到sim卡
  static const ResultValue noSim = ResultValue._(600007);

  ///蜂窝网络未开启
  static const ResultValue noNet = ResultValue._(600008);

  ///无法判断运营商
  static const ResultValue operatorCheckError = ResultValue._(600009);

  ///未知异常
  static const ResultValue error = ResultValue._(600010);

  ///获取token失败
  static const ResultValue getTokenError = ResultValue._(600011);

  ///获取预取号失败
  static const ResultValue getNumError = ResultValue._(600012);

  ///运营商维护升级 该功能不可用
  static const ResultValue operatorUpadate = ResultValue._(600013);

  ///运营商维护升级，该功能已达最大调用次数
  static const ResultValue operatorMax = ResultValue._(600014);

  ///接口超时
  static const ResultValue apiTimeOut = ResultValue._(600015);

  ///AppID、Appkey解析失败
  static const ResultValue appidError = ResultValue._(600017);

  ///点击登录时检测到运营商已切换
  static const ResultValue operatorChage = ResultValue._(600021);

  ///加载⾃定义控件异常
  static const ResultValue customViewError = ResultValue._(600023);

  ///终端环境检查⽀持认证
  static const ResultValue deviceCheckSuccess = ResultValue._(600024);

  ///终端检测参数错误
  static const ResultValue paramsError = ResultValue._(600025);

  ///授权页已加载时不允许调用加速或预取号接口
  static const ResultValue apiCantUse = ResultValue._(600026);

  static const values = [
    getTokenSuccess,
    pageOpenSuccess,
    pageOpenError,
    operatorInfoError,
    unSafe,
    noSim,
    noNet,
    operatorCheckError,
    error,
    getTokenError,
    getNumError,
    operatorUpadate,
    operatorMax,
    apiTimeOut,
    appidError,
    operatorChage,
    customViewError,
    deviceCheckSuccess,
    paramsError,
    apiCantUse
  ];


  static ResultValue? checkValue(int code) {
    try {
      ResultValue value = values
          .where((element) => element.type == code)
          .first;
      return value;
    }catch(e){
      return null;
    }

  }

}